<template>
  <div class="formChild">
    <p class="subTitle">{{source.LBL}}</p>
    <div class="cont">
      <p class="desc">{{source.DESC}}</p>
      <div class="formItems" v-if="source.OPTIONS">
        <el-checkbox-group v-model="checkboxSelected" :min="source.MIN" :max="source.MAX">
          <el-checkbox
            v-for="(item,index) in source.OPTIONS"
            :key="index"
            :label="index"
          >{{item.VAL}}</el-checkbox>
        </el-checkbox-group>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "formCheckbox",
  props: {
    source: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  computed: {
    checkboxSelected() {
      let indexArr = [];
      if (this.source.OPTIONS) {
        let opts = this.source.OPTIONS;
        for (let i = 0; i < opts.length; i++) {
          if (opts[i].CHKED === "1") {
            indexArr.push(i)
          }
        }
      }
      return indexArr;
    }
  },
};
</script>
<style lang="scss" scoped src="./com.scss"></style>
<style lang="scss" scoped>
.el-checkbox-group {
  line-height: 36px;
}
</style>